window.onload = function() {

    var booleanVal = false; //是否点击跳转标记
    var columns = [
    	{ field: 'id', title: '编号', align: "center" },
        { field: 'code', title: '报表编码', align: "center" },
        { field: 'name', title: '报表名称', align: "center" },
        { field: 'source', title: '报表来源', align: "center" },
        { field: 'address', title: '异步任务地址', align: "center" },
        { field: 'overtime', title: '报表超时时长', align: "center" },

    ]
    tableData = {
        initData: function(val) {
            $('#table').bootstrapTable({
                method: 'get',
                contentType: 'application/json',
                url: "/all",
                dataField: "data",
                pageNumber: 1,
                uniqueId: "roleId",
                pagination: true,
                cache: false,
                escape: true,
                queryParams: function(params) {

                    return {
//                        pageSize: params.limit,
//                        page: params.offset / params.limit + 1,
                        pageSize: 100,
                        page: 1,
                        code: $("#code").val(),
                        name: $("#name").val()
                    }
                },
                sidePagination: 'server',
                pageSize: 100,
//                pageList: [10, 20, 50],
                responseHandler: function(result) {
	                return {
	                    total: result.length,
	                    data: result
	                };
                    
                },
                paginationPreText: "上一页",
                paginationNextText: "下一页",
                showHeader: true,
                columns: columns,
                onClickRow: function(row, $element) {
                    defaultParams = row
                    $($element).addClass("changeColor").siblings().removeClass("changeColor")
                    if (booleanVal) {
                        $("#buttonDetail").click()
                    }
                },
                onDblClickRow: function(row) {
                    defaultParams = row
                    $("#buttonDetail").click()
                },
                onClickCell: function(row, $element) {
                    if (row == "eventId") {
                        booleanVal = true
                    } else {
                        booleanVal = false
                    }
                }
            });
            // 
        }
    }

    tableData.initData("")
}
